/*程序6-5*/
#include <stdio.h>

int main(void) {
    int i, n, min_index;
    int a[10];

    printf("Enter n: ");
    scanf("%d", &n);

    // 输入数组元素
    for (i = 0; i < n; i++) {
        printf("a[%d] = ", i);
        scanf("%d", &a[i]);
    }
    //a[0]做临时最小值
    min_index = 0;
    // 从a[1]开始比较
    for (i = 1; i < n; i++) {
        if (a[i] < a[min_index]) {
            // 记录最小值的下标
            min_index = i;
        }
    }

    printf("min is %d \n", a[min_index]);
    printf("min_index is %d \n", min_index);
    return 0;
}
